<extend name="Public/group"/>

<block name="body">

<div class="clearfix post_content">
<div class=" clearfix col-xs-12 group_block_border " style="background: white">
<div style="margin-top: 15px"></div>
<php>
    $user = query_user(array('avatar128','uid','nickname','space_url','icons_html','rank_link','space_link'),
    $post['uid']);
</php>
<if condition="$showMainPost">
    <div class="row" style="position: relative">
        <div class="group_left_operation hidden-xs">
            <div class="text-right btn-toolbar btn-group-vertical" role="toolbar">
                <div class="btn-group">
                    <if condition="($post['uid']==is_login()) OR (is_administrator())">
                        <a class="btn" title="编辑"
                           href="{:U('Index/edit',array('post_id'=>$post['id']))}">
                            <i class="group_edit"></i>
                        </a>
                    </if>
                    <a class="btn" title="回复" href="#reply_form">
                        <i class="group_reply"></i></a>


                    <php>
                        $hideStyle = 'display: none;';
                        $bookmarkStyle = $isBookmark ? $hideStyle : '';
                        $unbookmarkStyle = $isBookmark ? '' : $hideStyle;
                    </php>
                    <a title="取消收藏" id="unbookmark_button" class="btn bookmark_btn"
                       style="{$unbookmarkStyle} padding-bottom: 10px"
                       data-url="{:U('Index/doBookmark?add=0',array('post_id'=>$post['id']))}">
                        <i class="group_uncollect"></i></a>

                    <a title="收藏本帖" id="bookmark_button" class="btn bookmark_btn"
                       style="{$bookmarkStyle} padding-bottom: 10px"
                       data-url="{:U('Index/doBookmark',array('post_id'=>$post['id']))}"><i
                            class="group_collect"></i></a>



                    <php>if($is_allow){</php>
                    <php>if(!$post['is_top']){</php>

                    <a title="置顶本帖" id="recommend" class="clearfix "
                       style="padding-bottom: 10px;float: left;margin: 5px 0 0 16px;"
                       data-url="{:U('Index/recommend',array('post_id'=>$post['id']))}"><i
                            class="glyphicon glyphicon-file"></i></a>
                    <php>}else{</php>

                    <a title="取消置顶本帖" id="unrecommend" class="clearfix "
                       style=" padding-bottom: 10px;float: left;margin: 5px 0 0 16px;color: rgb(214,31,57) !important;"
                       data-url="{:U('Index/recommend',array('post_id'=>$post['id'],'top'=>0))}"><i
                            class="glyphicon glyphicon-file"></i></a>
                    <php>}</php>
                    <php>}</php>

                </div>
            </div>
        </div>
        <div class="col-md-2 text-center">
            <p  class="">
                <a href="{$user.space_url}" ucard="{$user.uid}"><img width="55px" src="{$user.avatar128}"
                                                                     class="avatar-img"/></a>
                <span class="hidden-lg hidden-md">
                <a  href="{$user.space_url}" ucard="{$user.uid}" style="margin-left: 10px;">{$user.nickname|htmlspecialchars}</a>
                {$user.icons_html}
                </span>

            </p>

            <p class="hidden-xs">
                <a href="{$user.space_url}" ucard="{$user.uid}">{$user.nickname|htmlspecialchars}</a>
                {$user.icons_html}
            </p>

            <p class="text-center">
                <volist name="user.rank_link" id="vo">
                    <if condition="$vo['is_show']"><img src="{$vo.logo_url}" title="{$vo.title|parseWeiboContent}"
                                                        alt="{$vo.title|parseWeiboContent}"
                                                        class="rank_html"/>
                    </if>
                </volist>
            </p>
        </div>
        <div class="col-md-10 ">
            <div class="row">
                <div style="position: relative">
                    <a class="ribbion-green1" href="{:U('group/index/group',array('type'=>'post','id'=>$post['group_id']))}" >返回群组</a>

                    <div style="padding: 15px"></div>
                    <div class="col-md-12 post_title">
                        <h2>{$post.title|op_t|parseWeiboContent}                 <if condition="$post['is_top'] eq 1"><img src="__IMG__/is_top.png"></if>
                            <if condition="$post['digest'] eq 1"><img src="__IMG__/digest.png"></if>
                        </h2>



                        <div class="small sub_title pull-left"><br/>

                            <a href="{$user.space_url}" ucard="{$user.uid}"
                               class="text-primary">{$user.nickname}</a> {$post.create_time|time_format} 发表在<a
                                    href="{:U('Group/Index/group',array('id'=>$post['group_id']))}">【{$post.group.title|parseWeiboContent}】</a>
                            <a href="{:U('posts',array('post_cate'=>$post['cate_id']))}">{$post.category}</a>
                            {:Hook('support',array('app'=>'Group',table=>'post','row'=>$post['id'],'uid'=>$post['uid'],'jump'=>'no'))}

<span class="visible-xs pull-right" style="margin-top: 2px;margin-left: 5px;">
                            <if condition="($post['uid']==is_login()) OR (is_administrator())">
                                <a class="xs_btn" title="编辑"
                                   href="{:U('Index/edit',array('post_id'=>$post['id']))}">
                                    <i class="group_edit"></i>
                                </a>
                            </if>
                            <a class="xs_btn" title="回复" href="#reply_form">
                                <i class="group_reply"></i></a>

                            <php>
                                $hideStyle = 'display: none;';
                                $bookmarkStyle = $isBookmark ? $hideStyle : '';
                                $unbookmarkStyle = $isBookmark ? '' : $hideStyle;
                            </php>
                            <a title="取消收藏" id="unbookmark_button" class="xs_btn bookmark_btn"
                               style="{$unbookmarkStyle} padding-bottom: 10px"
                               data-url="{:U('Index/doBookmark?add=0',array('post_id'=>$post['id']))}">
                                <i class="group_uncollect"></i></a>

                            <a title="收藏本帖" id="bookmark_button" class="xs_btn bookmark_btn"
                               style="{$bookmarkStyle} padding-bottom: 10px"
                               data-url="{:U('Index/doBookmark',array('post_id'=>$post['id']))}"><i
                                    class="group_collect"></i></a>

                                <php>if($is_allow){</php>
                                <php>if(!$post['is_top']){</php>

                                <a title="置顶本帖" id="recommend" class=" "
                                   style="padding-bottom: 10px;"
                                   data-url="{:U('Index/recommend',array('post_id'=>$post['id']))}"><i style="top: -2px"
                                        class="glyphicon glyphicon-file"></i></a>
                                <php>}else{</php>

                                <a title="取消置顶本帖" id="unrecommend" class=" "
                                   style=" padding-bottom: 10px;color: #bc0000 !important;"
                                   data-url="{:U('Index/recommend',array('post_id'=>$post['id'],'top'=>0))}"><i style="top: -2px"
                                        class="glyphicon glyphicon-file"></i></a>
                                <php>}</php>
                                <php>}</php>
</span>
                        </div>
                    </div>

                </div>
            </div>
            <div style="padding: 10px"></div>
            <div class="col-md-12 main_content" style="margin-left: -15px">
                {$post.content|parse_popup|parse_at_users|parseWeiboContent}


                <php>if($post['attachment_count']>0){</php>
<div style="margin-top: 30px;">
                <h2>附件下载</h2>
<volist name="post['attachment']" id="atta">
    <p>
        <a href="{:U('home/file/downloadFile',array('id'=>$atta['id']))}">{$atta.name}</a>
    </p>

</volist>

</div>
                <php>}</php>


            </div>
            <div>


                <br/>
                <if condition="$post['create_time'] != $post['update_time']">
                    <p class="text-muted">
                        [最后编辑于 {$post['update_time']|time_format} ]
                    </p>
                </if>
            </div>
            <div>
                <div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#"
                                                                                                  class="bds_qzone"
                                                                                                  data-cmd="qzone"
                                                                                                  title="分享到QQ空间"></a><a
                        href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq"
                                                                                           data-cmd="tqq"
                                                                                           title="分享到腾讯微博"></a><a
                        href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a><a href="#"
                                                                                            class="bds_weixin"
                                                                                            data-cmd="weixin"
                                                                                            title="分享到微信"></a><a
                        href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a><a href="#" class="bds_copy"
                                                                                           data-cmd="copy"
                                                                                           title="分享到复制网址"></a>
                </div>
                <script>window._bd_share_config = {"common": {"bdSnsKey": {}, "bdText": "", "bdMini": "2", "bdMiniList": false, "bdPic": "", "bdStyle": "1", "bdSize": "16"}, "share": {}};
                with (document)0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];</script>
                <style>
                    #bdshare_weixin_qrcode_dialog{
                        min-height:326px;
                    }
                </style>
            </div>

        </div>
    </div>

    <hr class="post_line"/>
</if>

<volist name="replyList" id="reply" key="k">
    <div class="row" style="position: relative">
        <a id="{$reply.id}" style="margin-top: -100px;position: absolute;"></a>
        <eq name="reply.uid" value="$post['uid']">
            <a class="ribbion-green">楼主</a>
        </eq>

        <div class="col-md-2 text-center">
            <p class="">
                <a ucard="{$reply.uid}" href="{$reply.user.space_url}"><img width="55px" src="{$reply.user.avatar128}"
                                                                            class="avatar-img"/></a>

                 <span class="hidden-lg hidden-md">
               <a ucard="{$reply.uid}" href="{$reply.user.space_url}" style="margin-left: 10px">{$reply.user.nickname}</a>
                {$reply.user.icons_html}
                </span>
            </p>

            <p class="hidden-xs">
                <a ucard="{$reply.uid}" href="{$reply.user.space_url}">{$reply.user.nickname}</a>
                {$reply.user.icons_html}
            </p>

            <p class="text-center">
                <volist name="reply.user.rank_link" id="vo">
                    <if condition="$vo['is_show']"><img src="{$vo.logo_url}" title="{$vo.title|parseWeiboContent}"
                                                        alt="{$vo.title|parseWeiboContent}"
                                                        class="rank_html"/>
                    </if>
                </volist>
            </p>
        </div>
        <div class="col-md-10">
            <div style="min-height: 10em;overflow: hidden;word-break: break-all" class="post_content">
                <div style="padding: 15px"></div>
                {$reply.content|parse_popup|parse_at_users|parseWeiboContent}
                <br/>
            </div>
            <p class="pull-right text-muted">
                {:getLou( $limit*($page-1)+$k+1)}
                发表于 {$reply.create_time|time_format}
                <if condition="CheckPermission(array($reply['uid']))">
                    <a href="javascript:" class="del_reply_btn" args="reply_id={$reply['id']}">删除</a>
                </if>
                <php>if($reply['uid']==is_login()){</php>
                <a href="{:U('Index/editReply',array('reply_id'=>$reply['id']))}">编辑</a>
                <php>}</php>

                <a href="javascript:" class="reply_btn" args="{$reply['id']}" id="reply_btn_{$reply['id']}">回复({$reply.lzl_count})</a>

            </p>

            <div class="clearfix"></div>
            <if condition="$reply['lzl_count'] eq 0"><?php $style="display:none"; ?></if>
            <div id="lzl_reply_div_{$reply['id']}" style="{$style}">
                {:W('LZLReply/LZLReply',array('to_f_reply_id'=>$reply['id'],'post_id'=>$post['id'],'reply_uid'=>$reply['uid'],'count'=>$reply['lzl_count']))}
            </div>

        </div>

        <hr class="post_line"/>
    </div>
</volist>

<div class="row clearfix">
    <div class="col-xs-12">
        <div class="pull-right">
            {:getPagination($replyTotalCount)}
        </div>
    </div>
</div>

<br/>

<!--发表回复-->
<if condition="is_login()">

    <php>if(!is_joined($post['group_id'])){</php>
    <p class="text-center text-muted" style="font-size: 3em; padding-top: 2em; padding-bottom: 2em;">需  <a class="attend"  data-group-id="{$post['group_id']}"
            href="javascript:">加入群组</a> 再回复</p>
    <php>}else{</php>
    <php>
        $user = query_user(array('avatar128'));
    </php>
    <div class="row">
        <div class="col-xs-2">
            <p class="text-center">
                <a href="{$user.space_url}" ucard="{$user.uid}">
                    <img src="{$user.avatar128}" width="48px" class="avatar-img"/></a>
            </p>
        </div>
        <div class="col-xs-10">
            <div id="reply_block">
                <form id="reply_form" action="{:U('doReply',array('post_id'=>$post['id']))}" method="post"
                      class="ajax-form">
                    <h4>发表回复</h4>

                    <p>
                        <php>$config='';</php>
                        {:W('UeditorMini/editor',array('contentEditor','content','','100%','250px',$config))}
                    </p>

                    <p class="pull-right">
                        <input type="submit" id="reply_button" class="btn btn-primary" value="发表 Ctrl+Enter"/>
                    </p>
                </form>
            </div>
        </div>
    </div>
    <php>}</php>
    <else/>
    <p class="text-center text-muted" style="font-size: 3em; padding-top: 2em; padding-bottom: 2em;">请<a
            href="{:U('Home/User/login')}">登录</a>后发帖</p>
</if>
</div>
</div>
<script>
    var SUPPORT_URL = "{:addons_url('Support://Support/doSupport')}";
    //点击收藏/取消收藏按钮
    $(function () {

        $('#reply_form').keypress(function (e) {
            if (e.ctrlKey && e.which == 13 || e.which == 10) {
                $('#reply_button').focus();
                $("#reply_form").submit();
            }
        });


        var $inputor = $('#contentEditor').atwho(atwho_config);

        bindSupport();
        $('#bookmark_button, #unbookmark_button').click(function (e) {

            //取消默认操作
            e.preventDefault();

            //发送AJAX请求
            var button = $(this);
            var href = button.attr('data-url');
            var originalClass = $(this).attr('class');
            button.attr('class', 'btn');
            $.post(href, {}, function (a) {
                button.attr('class', originalClass);
                if (a.status) {
                    toast.success(a.info);
                    switchButtonVisibility();
                }
            });

            return false;
        });

        function switchButtonVisibility() {
            switchVisibility('#bookmark_button');
            switchVisibility('#unbookmark_button');
        }

        function switchVisibility(css) {
            var element = $(css);
            if (element.is(':visible')) {
                element.hide();
            } else {
                element.show();
            }
        }

        if ("{$sr}" != "") {
            $('#lzl_reply_list_{$sr}').load(U('group/lzl/lzllist', ['to_f_reply_id', '{$sr}', 'page', '{$sp}'], true), function () {
                ucard();
            });
        }
        <php>if($is_allow){</php>
        $('#recommend,#unrecommend').click(function () {
            var obj = $(this);
            $.post(obj.attr('data-url'), {}, function (a) {
        handleAjax(a)
            })
        })
            <php>}</php>


    })


</script>

<script>

    $(document).ready(function () {
        $('.popup-gallery').each(function () { // the containers for all your galleries
            $(this).magnificPopup({
                delegate: '.popup',
                type: 'image',
                tLoading: 'Loading image #%curr%...',
                mainClass: 'mfp-img-mobile',
                gallery: {
                    enabled: true,
                    navigateByImgClick: true,
                    preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
                },
                image: {
                    tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
                    titleSrc: function (item) {
                        /*           return item.el.attr('title') + '<small>by Marsel Van Oosten</small>';*/
                        return '';
                    }
                }
            });
        });
    });
</script>
<style>
    .group-first-block {
        background: white;
        box-shadow: 0 0 5px rgb(204, 204, 204);
        -moz-box-shadow: 0 0 5px #CCCCCC;
        -khtml-box-shadow: 0 0 5px #CCCCCC;
        margin-top: 15px;
    }
</style>
</block>
